<?php
/**
 * Created by PhpStorm.
 * User: lyang
 * Date: 2017/1/1
 * Time: 0:09
 */
function article_by_id($id){
    $db = YC::make("DB");
    $data = $db->get(
        "yc_article",
        "*",
        [
            "id[=]"=>$id
        ]
    );
    return $data;
}
function article_list($argv){
    $cond =[];
    $type = isset($argv["category"]) && !empty($argv["category"])?$argv["category"]:'';
    if(!empty($type)){
        $cond = array_merge($cond,[
            "category[=]"=>$type,
        ]);
    }
    $page = isset($argv["page"])?$argv["page"]:1;
    $page = intval($page)>0?$page:0;
    $page--;
    $size = 15;
    $cond = array_merge($cond,[
        "LIMIT"=>[$page*$size,$size]
    ]);
    $db = YC::make("DB");
    $data = $db->select(
        "yc_article",
        "*",
        $cond
    );
    return $data;
}